package com.zxq.lawenf.pojo;

import com.zxq.common.pojo.BasePojo;
import com.zxq.users.pojo.AAdmins;
import com.zxq.users.pojo.AUsers;

import java.util.Date;
import java.util.Map;
import java.util.TreeMap;

/**
 * 示例代码中的历史表
 * ~类名为表名,去掉下划线;
 * ~下划线隔开的单词要采用驼峰标识
 * @author 章晓琦
 */
public class AHistory extends BasePojo<AHistory>
{
	private int id;
	private int usersId;
	private int adminsId;
	private int relaId;
	private String content;
	private byte hisType;
	private byte status;
	private Date createTime;
	private Date updateTime;
	private Date pubTime;

	/*--关联关系--*/
	private AUsers users ;
	private AAdmins admins ; 
	
	/*--字符串表示--*/
	private String statusStr ; 
	private String hisTypeStr ;
	/* 存储所有状态的容器 */
	private Map<String,String> enumsMap = new TreeMap<String, String>();

	/**
	 * 获取此表相关的所有枚举值
	 * @return	键为枚举的变量名+枚举的值; 值为枚举的名字
	 * 			如:key:STATUS_ENABLE-1,值:启用
	 */
	public Map<String, String> getEnumsMap()
	{
		// 根据状态值获取字符串描述
		AHistoryEnum[] enums = AHistoryEnum.values();
		for (int i = 0; i < enums.length; i++)
		{
			AHistoryEnum enumTemp = enums[i];
			String key = enumTemp.toString() ; 
			enumsMap.put(key + "-" + enumTemp.getStatus() + "", enumTemp.getName());
		}
		return enumsMap;
	}
	
	/**
	 * 获取状态的字符串描述
	 * @return	此状态对应的字符串描述
	 */
	public String getStatusStr()
	{
		// 根据状态值获取字符串描述
		AHistoryEnum[] enums = AHistoryEnum.values();
		for (int i = 0; i < enums.length; i++)
		{
			AHistoryEnum enumTemp = enums[i];
			if (enumTemp.toString().startsWith("STATUS_"))
			{
				// 表示是状态的标识
				if (enumTemp.getStatus() == this.getStatus())
				{
					this.statusStr = enumTemp.getName();
					break;
				}
			}
		}
		return statusStr;
	}
	
	/**
	 * 获取状态的字符串描述
	 * @return	此状态对应的字符串描述
	 */
	public String getHisTypeStr()
	{
		// 根据状态值获取字符串描述
		AHistoryEnum[] enums = AHistoryEnum.values();
		for (int i = 0; i < enums.length; i++)
		{
			AHistoryEnum enumTemp = enums[i];
			if (enumTemp.toString().startsWith("HISTYPE_"))
			{
				// 表示是状态的标识
				if (enumTemp.getStatus() == this.getHisType())
				{
					this.hisTypeStr = enumTemp.getName();
					break;
				}
			}
		}
		return hisTypeStr;
	}

	public int getId()
	{
		return id;
	}

	public void setId(int id)
	{
		this.id = id;
	}

	public int getUsersId()
	{
		return usersId;
	}

	public void setUsersId(int usersId)
	{
		this.usersId = usersId;
	}

	public int getAdminsId()
	{
		return adminsId;
	}

	public void setAdminsId(int adminsId)
	{
		this.adminsId = adminsId;
	}

	public int getRelaId()
	{
		return relaId;
	}

	public void setRelaId(int relaId)
	{
		this.relaId = relaId;
	}

	public String getContent()
	{
		return content;
	}

	public void setContent(String content)
	{
		this.content = content;
	}

	public byte getHisType()
	{
		return hisType;
	}

	public void setHisType(byte hisType)
	{
		this.hisType = hisType;
	}

	public byte getStatus()
	{
		return status;
	}

	public void setStatus(byte status)
	{
		this.status = status;
	}

	public Date getCreateTime()
	{
		return createTime;
	}

	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}

	public Date getUpdateTime()
	{
		return updateTime;
	}

	public void setUpdateTime(Date updateTime)
	{
		this.updateTime = updateTime;
	}

	public Date getPubTime()
	{
		return pubTime;
	}

	public void setPubTime(Date pubTime)
	{
		this.pubTime = pubTime;
	}

	public AUsers getUsers()
	{
		return users;
	}

	public void setUsers(AUsers users)
	{
		this.users = users;
	}

	public AAdmins getAdmins()
	{
		return admins;
	}

	public void setAdmins(AAdmins admins)
	{
		this.admins = admins;
	}
}
